package com.arnold.test.transformations

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by arnold.zhu on 2017/7/14.
  */
object ReduceByKey {


  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("Spark01Learn")
    val sc = new SparkContext(conf)

    //  接收一个Scala的集合
    val kv1 = sc.parallelize(List(("A", 1), ("B", 2), ("C", 3), ("A", 4), ("B", 5)))

    kv1.reduceByKey((x, y) => x + y).collect.foreach {
      println(_)
    }

    sc.stop()
  }

}
